package com.buu.manager.controller;

import com.buu.common.annotation.Log;
import com.buu.common.utils.R;
import com.buu.manager.domain.EduDO;
import com.buu.manager.service.EduService;
import com.buu.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 学生注册
 */
@RequestMapping("/registry")
@Controller
public class RegsitryController {

    @Autowired
    private UserService userService;

    @Autowired
    private EduService eduService;

    @PostMapping("/exsit")
    @ResponseBody
    boolean exsit(@RequestParam("username") String username) {
        return !userService.exit(username);// 存在，不通过，false
    }

    @Log("保存用户信息")
    @ResponseBody
    @PostMapping("/save")
    R save(EduDO eduDo) {

        if (eduService.save(eduDo) > 0) {
            return R.ok();
        }
        return R.error();
    }
}
